package bastanteo.servlet;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bastanteo.modelo.Bastanteo;
import bastanteo.modelo.GrupoBastanteo;
import bastanteo.negocio.BastanteoNegocio;
import bastanteo.negocio.GrupoNegocio;

/**
 * Servlet implementation class ProductosBuscarServlet
 */
@WebServlet("/PoderConsultaServlet")
public class PoderConsultaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public PoderConsultaServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

			String ruc = request.getParameter("txtruc");
			String grup = request.getParameter("txtbusqueda");
			
			try {
				BastanteoNegocio bn = new BastanteoNegocio();
				Collection<Bastanteo> cp = bn.ConsultarPoderes(ruc, grup);
				
				//ProductosNegocio negocio = new ProductosNegocio();
				request.setAttribute("cpoder", cp);
			} catch (Exception e) {
				request.setAttribute("cpoder", null);
				System.out.println(e.getMessage());
			}	
			RequestDispatcher rd = request.getRequestDispatcher("consultarpoderes.jsp");
			rd.forward(request, response);

//		}
	}

}
